<?php
if(!isset($_SESSION['user_id'])) {
	echo '<script>location.href=\'../index.php?page=login\'</script>';
}	
?>
<link href="css/Site.css" rel="stylesheet" type="text/css" />
<script src="js/ZeroClipboard.js" type="text/javascript"></script>
<script src="js/tooltip.js" type="text/javascript"></script>
<script src="js/ajaxupload.js" type="text/javascript"></script>
<style type="text/css">
a.image
{
	text-decoration:none!important;
	 color: #0488B9;
    font-family: Arial;
    font-size: 13px;
    font-weight: bold;
    
	
}
a.image:hover
{
	text-decoration:none!important;
	 color: #000;
    font-family: Arial;
    font-size: 13px;
    font-weight: bold;
    text-decoration: none;
	
}
.makeup {
	border: 1px solid #ebebeb;
	padding: 5px;
	height: 15px;
	width: 300px;
	vertical-align: middle;
}

</style>

<script type="text/javascript">
<?php
	$true_host = $_SERVER['HTTP_HOST'];
	echo 'var true_uri ="http://'.$true_host.'";';
?>
var citationList = "";
var citationToInsert = "";
function delete_assignment(id)
{
	if (confirm('Do you want to delete this assignment?'))
	{
		$.post("application/action.php", 
			{module : 'delete_assignment', assignment_id : id}, 
			function(data){
				if (data == "1")
				{
					var trCurrent = tag.parentNode.parentNode;
					var trNext = trCurrent.nextSibling;
					if (trNext.tagName == "TR")
					{
						$(trNext).remove();
					}
					else
					{										
						$(trNext.nextSibling).remove();
					}
					$(trCurrent).remove();
				}
			}
		);
	}	
}

function Del_Refernce(str)
{
if (str=="")
  { 
  document.getElementById("DelReference").innerHTML="";
  return;
  } 

  if(window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
    }


xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {  
    document.getElementById("DelReference").innerHTML=xmlhttp.responseText;
	
    }
  }
//xmlhttp.open("GET","http://localhost/studyage/view/reference.php?id="+str,true);
xmlhttp.open("GET",true_uri+"/view/reference.php?id="+str,true);
xmlhttp.send();
}
</script>
<SCRIPT language="javascript">

function checkQuotationValid()
	{
		var editor = $(".nicEdit-main [contenteditable]");
		var text = editor.text();
		var isValid = true;
		/*
		if (/\(.*,\d*,p..*\)/.test(text))
		{
			isValid = /".+"\(.+,\d+,p\..+\)/.test(text);
		}
		else if (/\(\d*,p..*\)/.test(text))
		{
			isValid = /.+\(\d+,p\..+\)".+"/.test(text);
		}
		*/
		if (/\(.*p\..*\)/.test(text))
		{
			isValid = /\(.*p\.\d+\)/.test(text);
		}		
		
		if (!isValid)
		{
			alert('Please enter citation page number in your assigment. Ex: Durai(2001,p.3)"London" or (Durai,2001,p.3)"London"');
		}
		
		return isValid;
	}

        function addRow(tableID) {
 
            var table = document.getElementById(tableID);
 
            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);

            var colCount = table.rows[0].cells.length;

            for(var i=0; i<colCount; i++) {
			
			
			 if(rowCount > 6) {
                        alert("You Can't Add More 8 Than Authors");
                        break;
                    }
                var newcell = row.insertCell(i);
 
                newcell.innerHTML = table.rows[0].cells[i].innerHTML;
				
                switch(newcell.childNodes[0].type) {
                    case "text":
                            newcell.childNodes[0].value = "";
                            break;
                    case "checkbox":
                            newcell.childNodes[0].checked = true;							
                            break;                    
                }
            }
			
        }
 
        function deleteRow(tableID) {
			
            try {
			var table = document.getElementById(tableID);
            var rowCount = table.rows.length;
			for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
				if(null != chkbox && true == chkbox.checked) {
                    if(rowCount <= 1) {
                        alert("Cannot delete all the rows.");
                        break;
                    }
                    table.deleteRow(i);
					rowCount--;
                    i--;
                }
 
            }
            }catch(e) {
                return false;
            }
        }
 
    </SCRIPT>
 
<script type="text/javascript">
function check_empty() {
	if($('#assignment_title').val() == "") {
		alert('Assignment title need to be filled.');
		$('#assignment_title').focus();
		return false;
	}
	return true;
}

$('.menu a,.header a').click(function(e){
  return checkSaveAssignmentLogout($(e.currentTarget).attr('href'));
});

function SaveAssignmentToAccount(frmName, str) {
	if (checkQuotationValid())
	{
		document.form4.method = "post";
		$('[name=area1]').val($(".nicEdit-main [contenteditable]").html());
		//document.form4.action = "http://localhost:8080/aw/application/savetoaccount.php";
		document.form4.action = true_uri + "/application/savetoaccount.php?url=" + escape(str);
		document.form4.submit();
	}
	else
	{
		return false;
	}
}

function validate_book() {
	if($('#title1').val() == "") {
		alert("Please Enter the Book Title");
		$('#title1').focus();
		return false;
	}
	if($('#pub1').val() == "") {
		alert("Please Enter the Publisher Field");
		$('#pub1').focus();
		return false;
	}
	if($('#pcity1').val() == "") {
		alert("Please Enter the Publisher's City");
		$('#pcity1').focus();
		return false;
	}
	if($('#date1').val() == "") {
		alert("Please Enter the Publication Year");
		$('#date1').focus();
		return false;
	}
	if($('#pages1').val() == "") {
		alert("Please Enter the Page numer");
		$('#pages1').focus();
		return false;
	}
	if($('#firstname1').val() == "") {
		alert("Please Enter First Name");
		$('#firstname1').focus();
		return false;
	}
	if($('#lastname1').val() == "") {
		alert("Please Enter Last Name");
		$('#lastname1').focus();
		return false;
	}
	return true;
}

function validate_journal() {
	if($('#title2').val() == "") {
		alert("Please Enter the Book Title");
		$('#title2').focus();
		return false;
	}
	if($('#journal2').val() == "") {
		alert("Please Enter the Journal Title");
		$('#journal2').focus();
		return false;
	}
	if($('#date2').val() == "") {
		alert("Please Enter the Publication Year");
		$('#date2').focus();
		return false;
	}
	if($('#pages2').val() == "") {
		alert("Please Enter the Page numer");
		$('#pages2').focus();
		return false;
	}
	if($('#firstname2').val() == "") {
		alert("Please Enter First Name");
		$('#firstname2').focus();
		return false;
	}
	if($('#lastname2').val() == "") {
		alert("Please Enter Last Name");
		$('#lastname2').focus();
		return false;
	}
	return true;
}

$(function(){
	$('#submit_book').click(function(){
			if(validate_book()) {
				generate_reference(0,temp);
			}
	});
	$('#submit_journal').click(function(){
			if(validate_journal()) {
				generate_reference(1,temp);
			}
	});
});

var temp = -1;

function show_generate_reference(e, v) {
temp = v;
	if(e == 0) {
		$('#generate_reference_journal').hide();
		$('#generate_reference_book').show();
		$('#submit_book').removeAttr('disabled');
		$('#title1').val("");
		$('#pub1').val("");
		$('#pcity1').val("");
		$('#date1').val("");
		$('#pages1').val("");
		$('#firstname1').val("");
		$('#lastname1').val("");
		$('#fromfile1').html("<b><i>File " + v + "</i></b>");
	}
	if(e == 1) {
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').show();
		$('#submit_journal').removeAttr('disabled');
		$('#title2').val("");
		$('#journal2').val("");
		$('#edition2').val("");
		$('#issue2').val("");
		$('#date2').val("");
		$('#pages2').val("");
		$('#digital2').val("");
		$('#fromfile2').html("<b><i>File " + v + "</i></b>");
	}	
}

// generate reference
function generate_reference(t, f) {
	$.ajax({
		type: "POST",
		//url: 'http://localhost:8080/aw/application/ajax_generate.php',
		url: true_uri+'/application/ajax_generate.php',
		data: ({type: t, assignment_title: $('#assignment_title').val(), title1: $('#title1').val(), pub1: $('#pub1').val(), pcity1: $('#pcity1').val(), date1: $('#date1').val(), edition1: $('#edition1').val(), pages1: $('#pages1').val(), firstname1: $('#firstname1').val(), lastname1: $('#lastname1').val(), title2: $('#title2').val(), journal2: $('#journal2').val(), edition2: $('#edition2').val(), issue2: $('#issue2').val(), date2: $('#date2').val(), pages2: $('#pages2').val(), digital2: $('#digital2').val(), firstnam2: $('#firstname2').val(), lastname2: $('#lastname2').val(), fileupload: $('#s_upload_file'+f).val(), userid: $('#userid').val(), t_r: $('#tr_a').val()}),
		cache: false,
		success:function(data, response) {
			if(t == 0) {
				$('#generate_reference_book').hide();
				$('#submit_book').attr('disabled', 'disabled');
			} else if(t == 1) {
				$('#generate_reference_journal').hide();
				$('#submit_journal').attr('disabled', 'disabled');
			}
			$('#book_journal' + f).attr('disabled', 'disabled');
			$('#book_journal_' + f).attr('disabled', 'disabled');
			$.get(true_uri+'/view/citation_list.php', function(data) {
				$('#reference').html(data);
			});
		}
	});
}

function show_citation(v) {
	$.ajax({
		type: "post",
		url: true_uri+'/view/citation_list.php',
		data: ({va: v, userid: <?php echo $_SESSION['user_id']; ?>}),
		dataType: 'html',
		cache: false,
		success: function(data) {
			$('#ktra').hide();
			$('#kqua').show();
			$('#kqua').html(data);
			$('#test_ed1').hide();
			//$('#test_ed2').load(true_uri+'/aw/view/test_load_editor.php');
			
			$.get(true_uri+'/view/test_load_editor.php', function(data) {
			  $('#test_ed2').html(data);
			  alert('Load was performed.');
			});
			$('#test_ed2').show();
		}
	});
}

function ktra() {
	var editor = $(".nicEdit-main [contenteditable]");
	if($('#flag').val() != 1) {
		if($('#assignment_title').val() == "") {
			alert("Please select References most appropriate for this assigment.");
			$('#assignment_title').focus();
		} else {
			if(editor.text() == "") {
				alert("Please select References most appropriate for this assigment.");
				$('#assignment_title').val();
				$('#assignment_title').focus();
			}
		}	
	}	
}

$(document).ready(function(){
var detail = $('#detail'), interval;
var detail2 = $('#detail2');
var detail3 = $('#detail3');
var detail4 = $('#detail4');
var detail5 = $('#detail5');
var detail6 = $('#detail6');
var detail7 = $('#detail7');
var detail8 = $('#detail8');
var detail9 = $('#detail9');
var detail10 = $('#detail10');
if($('#flag').val() == 1) {
	//DISABLE TEMPORARY - VUONG
	//$('#btn_upload').show();
}
//var url_upload = 'http://localhost:8080/aw/application/upload_file.php';
var url_upload = true_uri+'/application/upload_file.php';
	//DISABLE TEMPORARY - VUONG
	/*
	new AjaxUpload('#btn_upload',{
		action: url_upload,
		name: 'file1',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail.text();
					if (text.length < 13){
						detail.text(text + '.');					
					} else {
						detail.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail.text(file + ' - Extension is not allowed.');
				$('#book_journal1').attr('disabled', 'disabled');
				$('#book_journal_1').attr('disabled', 'disabled');
				return false;
			}
			//this.disable();
		},
		onComplete: function(file, response){
			$('#btn_upload').hide();
			$('#btn_upload2').show();
			$('#wrapall').show();
			$('#wrap_detail').show();
			window.clearInterval(interval);
			if(response == "a") {
				detail.text('Uploading file got error.');
				$('#s_upload_file1').val("");
			} else {
				$('#s_upload_file1').val(response);
				detail.text(file);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	*/
	new AjaxUpload('#btn_upload2',{
		action: url_upload,
		name: 'file2',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail2').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail2.text();
					if (text.length < 13){
						detail2.text(text + '.');					
					} else {
						detail2.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail2.text(file + ' - Extension is not allowed.');
				$('#book_journal2').attr('disabled', 'disabled');
				$('#book_journal_2').attr('disabled', 'disabled');
				return false;
			}
			//this.disable();
		},
		onComplete: function(file, response){
			$('#btn_upload2').hide();
			$('#btn_upload3').show();
			$('#wrapall').show();
			$('#wrap_detail2').show();
			window.clearInterval(interval);
			if(response == "b") {
				detail2.text('Uploading file got error.');
				$('#s_upload_file2').val("");
			} else {
				detail2.text(file);
				$('#s_upload_file2').val(response);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	new AjaxUpload('#btn_upload3',{
		action: url_upload,
		name: 'file3',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail3').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail3.text();
					if (text.length < 13){
						detail3.text(text + '.');					
					} else {
						detail3.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail3.text(file + ' - Extension is not allowed.');
				$('#book_journal3').attr('disabled', 'disabled');
				$('#book_journal_3').attr('disabled', 'disabled');
				return false;
			}
			//this.disable();
		},
		onComplete: function(file, response){
			$('#btn_upload3').hide();
			$('#btn_upload4').show();
			$('#wrapall').show();
			$('#wrap_detail3').show();
			window.clearInterval(interval);
			if(response == "c") {
				detail3.text('Uploading file got error.');
				$('#s_upload_file3').val("");
			} else {
				detail3.text(file);
				$('#s_upload_file3').val(response);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	new AjaxUpload('#btn_upload4',{
		action: url_upload,
		name: 'file4',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail4').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail4.text();
					if (text.length < 13){
						detail4.text(text + '.');					
					} else {
						detail4.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail4.text(file + ' - Extension is not allowed.');
				$('#book_journal4').attr('disabled', 'disabled');
				$('#book_journal_4').attr('disabled', 'disabled');
				return false;
			}
			//this.disable();
		},
		onComplete: function(file, response){
			$('#btn_upload4').hide();
			$('#btn_upload5').show();
			$('#wrapall').show();
			$('#wrap_detail4').show();
			window.clearInterval(interval);
			if(response == "d") {
				detail4.text('Uploading file got error.');
				$('#s_upload_file4').val("");
			} else {
				detail4.text(file);
				$('#s_upload_file4').val(response);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	new AjaxUpload('#btn_upload5',{
		action: url_upload,
		name: 'file5',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail5').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail5.text();
					if (text.length < 13){
						detail5.text(text + '.');					
					} else {
						detail5.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail5.text(file + ' - Extension is not allowed.');
				$('#book_journal5').attr('disabled', 'disabled');
				$('#book_journal_5').attr('disabled', 'disabled');
				return false;
			}
			//this.disable();
		},
		onComplete: function(file, response){
			$('#btn_upload5').hide();
			$('#btn_upload6').show();
			$('#wrapall').show();
			$('#wrap_detail5').show();
			window.clearInterval(interval);
			if(response == "e") {
				detail5.text('Uploading file got error.');
				$('#s_upload_file5').val("");
			} else {
				detail5.text(file);
				$('#s_upload_file5').val(response);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	new AjaxUpload('#btn_upload6',{
		action: url_upload,
		name: 'file6',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail6').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail6.text();
					if (text.length < 13){
						detail6.text(text + '.');					
					} else {
						detail6.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail6.text(file + ' - Extension is not allowed.');
				$('#book_journal6').attr('disabled', 'disabled');
				$('#book_journal_6').attr('disabled', 'disabled');
				return false;
			}
			//this.disable();
		},
		onComplete: function(file, response){
			$('#btn_upload6').hide();
			$('#btn_upload7').show();
			$('#wrapall').show();
			$('#wrap_detail6').show();
			window.clearInterval(interval);
			if(response == "f") {
				detail6.text('Uploading file got error.');
				$('#s_upload_file6').val("");
			} else {
				detail6.text(file);
				$('#s_upload_file6').val(response);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	new AjaxUpload('#btn_upload7',{
		action: url_upload,
		name: 'file7',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail7').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail7.text();
					if (text.length < 13){
						detail7.text(text + '.');					
					} else {
						detail7.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail7.text(file + ' - Extension is not allowed.');
				$('#book_journal7').attr('disabled', 'disabled');
				$('#book_journal_7').attr('disabled', 'disabled');
				return false;
			}
			//this.disable();
		},
		onComplete: function(file, response){
			$('#btn_upload7').hide();
			$('#btn_upload8').show();
			$('#wrapall').show();
			$('#wrap_detail7').show();
			window.clearInterval(interval);
			if(response == "g") {
				detail7.text('Uploading file got error.');
				$('#s_upload_file7').val("");
			} else {
				detail7.text(file);
				$('#s_upload_file7').val(response);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	new AjaxUpload('#btn_upload8',{
		action: url_upload,
		name: 'file8',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail8').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail8.text();
					if (text.length < 13){
						detail8.text(text + '.');					
					} else {
						detail8.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail8.text(file + ' - Extension is not allowed.');
				$('#book_journal8').attr('disabled', 'disabled');
				$('#book_journal_8').attr('disabled', 'disabled');
				return false;
			}
			//this.disable();
		},
		onComplete: function(file, response){
			$('#btn_upload8').hide();
			$('#btn_upload9').show();
			$('#wrapall').show();
			$('#wrap_detail8').show();
			window.clearInterval(interval);
			if(response == "h") {
				detail8.text('Uploading file got error.');
				$('#s_upload_file8').val("");
			} else {
				detail8.text(file);
				$('#s_upload_file8').val(response);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	new AjaxUpload('#btn_upload9',{
		action: url_upload,
		name: 'file9',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail9').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail9.text();
					if (text.length < 13){
						detail9.text(text + '.');					
					} else {
						detail9.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail9.text(file + ' - Extension is not allowed.');
				$('#book_journal9').attr('disabled', 'disabled');
				$('#book_journal_9').attr('disabled', 'disabled');
				return false;
			}
			//this.disable();
		},
		onComplete: function(file, response){
			$('#btn_upload9').hide();
			$('#btn_upload10').show();
			$('#wrapall').show();
			$('#wrap_detail9').show();
			window.clearInterval(interval);
			if(response == "i") {
				detail9.text('Uploading file got error.');
				$('#s_upload_file9').val("");
			} else {
				detail9.text(file);
				$('#s_upload_file9').val(response);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	new AjaxUpload('#btn_upload10',{
		action: url_upload,
		name: 'file10',
		autoSubmit: true,
		onChange: function(file, extension){},
		onSubmit: function(file, extension){
			$('#wrapall').show();
			$('#wrap_detail10').show();
			if(extension && /^(pdf|doc)$/.test(extension)){
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = detail10.text();
					if (text.length < 13){
						detail10.text(text + '.');					
					} else {
						detail10.text('Uploading');				
					}
				}, 200);
			} else {
				// extension is not allowed
				detail10.text(file + ' - Extension is not allowed.');
				$('#book_journal10').attr('disabled', 'disabled');
				$('#book_journal_10').attr('disabled', 'disabled');
				return false;
			}
			this.disable();
		},
		onComplete: function(file, response){
			$('#wrapall').show();
			$('#wrap_detail10').show();
			window.clearInterval(interval);
			if(response == "j") {
				detail10.text('Uploading file got error.');
				$('#s_upload_file10').val("");
			} else {
				detail10.text(file);
				$('#s_upload_file10').val(response);
				alert('Please be advised that the uploaded document will be deleted after seven days. Ensure you use it within that timeframe');
			}
		}
	});
	$('#cancel1').click(function() {
		$('#wrap_detail').hide();
		$('#s_upload_file1').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#submit_book').removeAttr('disabled');
		$('#book_journal1').removeAttr('disabled');
		$('#book_journal_1').removeAttr('disabled');
	});
	$('#cancel2').click(function() {
		$('#wrap_detail2').hide();
		$('#s_upload_file2').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#book_journal2').removeAttr('disabled');
		$('#book_journal_2').removeAttr('disabled');
	});
	$('#cancel3').click(function() {
		$('#wrap_detail3').hide();
		$('#s_upload_file3').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#book_journal3').removeAttr('disabled');
		$('#book_journal_3').removeAttr('disabled');
	});
	$('#cancel4').click(function() {
		$('#wrap_detail4').hide();
		$('#s_upload_file4').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#book_journal4').removeAttr('disabled');
		$('#book_journal_4').removeAttr('disabled');
	});
	$('#cancel5').click(function() {
		$('#wrap_detail5').hide();
		$('#s_upload_file5').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#book_journal5').removeAttr('disabled');
		$('#book_journal_5').removeAttr('disabled');
	});
	$('#cancel6').click(function() {
		$('#wrap_detail6').hide();
		$('#s_upload_file6').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#book_journal6').removeAttr('disabled');
		$('#book_journal_6').removeAttr('disabled');
	});
	$('#cancel7').click(function() {
		$('#wrap_detail7').hide();
		$('#s_upload_file7').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#book_journal7').removeAttr('disabled');
		$('#book_journal_7').removeAttr('disabled');
	});
	$('#cancel8').click(function() {
		$('#wrap_detail8').hide();
		$('#s_upload_file8').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#book_journal8').removeAttr('disabled');
		$('#book_journal_8').removeAttr('disabled');
	});
	$('#cancel9').click(function() {
		$('#wrap_detail9').hide();
		$('#s_upload_file9').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#book_journal9').removeAttr('disabled');
		$('#book_journal_9').removeAttr('disabled');
	});
	$('#cancel10').click(function() {
		$('#wrap_detail10').hide();
		$('#s_upload_file10').val("");
		$('#generate_reference_book').hide();
		$('#generate_reference_journal').hide();
		$('#book_journal10').removeAttr('disabled');
		$('#book_journal_10').removeAttr('disabled');
	});
});	
</script>
<?php
//echo '<pre>';
//print_r($_REQUEST);die;
if(isset($_POST['SubmitCompose']))
{
	
	$parentDir = dirname(dirname(__FILE__));
	require_once $parentDir . '/application/dataAccess.php';
	$da = new dataAccess();
	$dets = $da->getDoupleQuoteText($_POST['area1']);
	$atitle = $da->getDoupleQuoteText($_POST['assignment_title']);
	
	// website is offline, save title & comments for temp
	if(isset($_SESSION['offline']) && $_SESSION['offline'] == 1) {
		$qry = "SELECT * FROM temp_data_offline WHERE userid='".$_SESSION['user_id']."'";
		$num = mysql_num_rows(mysql_query($qry));
		if($num != 0) {
			$sql = "update temp_data_offline set assignmenttitle='".$atitle."', comment='".$dets."' WHERE userid='".$_SESSION['user_id']."'";
			$res = mysql_query($sql);
		} else {
			$sql = "insert into temp_data_offline set userid='".$_SESSION['user_id']."', assignmenttitle='".$atitle."', comment='".$dets."'";
			$res = mysql_query($sql);
		}
		unset($_SESSION['user_id']);
		header('location:maintenance.php');
	} else {
	$da->deleteTemp_data_offline($_SESSION['user_id']);
	$s_upload_file1 = $_POST['s_upload_file1'];
	$s_upload_file2 = $_POST['s_upload_file2'];
	$s_upload_file3 = $_POST['s_upload_file3'];
	$s_upload_file4 = $_POST['s_upload_file4'];
	$s_upload_file5 = $_POST['s_upload_file5'];
	$s_upload_file6 = $_POST['s_upload_file6'];
	$s_upload_file7 = $_POST['s_upload_file7'];
	$s_upload_file8 = $_POST['s_upload_file8'];
	$s_upload_file9 = $_POST['s_upload_file9'];
	$s_upload_file10 = $_POST['s_upload_file10'];
	//$atitle = $_POST['assignment_title'];
	$tr_post = intval($_POST['tr_post']);
	/*$pattern=substr($dets,-3);
	if($pattern=="p.)")
		echo "$dets";
	else
	{*/
	/*	$parentDir = dirname(dirname(__FILE__));
		require_once $parentDir . '/application/pdf2text.php';
		require_once $parentDir . '/application/dataAccess.php';
		if($_FILES['uploads']['name'])
		{
			if (!is_dir("uploads"))
		  	{
		  		mkdir("uploads");
		  	}

		  	if (!is_dir("uploads/assignment"))
		  	{
		  		mkdir("uploads/assignment");
		  	}
		  	
			$rand=date("Ymdhis");
			$sourcename = "assignment_".$rand."_".$_FILES['uploads']['name'];
			$file_name = "uploads/assignment/".$sourcename;			
			move_uploaded_file($_FILES['uploads']['tmp_name'], $file_name);			
			$ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));			
			if ($ext == "pdf")
			{				
				$content = trim(pdf2text($file_name));				
				$content = preg_replace('/\r|\n/', "", $content);				
				$da = new dataAccess();				
				$userName = $da->getFirstNameByID($_SESSION['user_id']);
				$da->addPdfTerm($content, $file_name, $file_name, date("Y"), $userName);								
			}			
		}
	*/	
		//$sql = mysql_query("insert into composedocument set comments='".$dets."',username='".$_SESSION['user_id']."',types='compose',uploads='$sourcename'");
		/*if(isset($_SESSION['file1'])) {
			$substr = substr($_SESSION['file1'], 0, 26);
			$nfilename1 = split($substr, $_SESSION['file1']);
			if($nfilename1[1] != $s_upload_file) {
				$nfilename1[1] = "";
			} else {
				$nfilename1[1] = $_SESSION['file1'];
			}
		} else {
			$nfilename1[1] = "";
		}
		$sql = "insert into composedocument set comments='".$dets."',username='".$_SESSION['user_id']."',types='compose',uploads='".$nfilename1[1]."'";
		$res = mysql_query($sql);
		if($res)
			header('location:index.php?page=assignment_manager&_v=c');*/
		//echo "<script>location.href='index.php?page=assignment_manager&_v=c';<//script>";
	//}
	$sql = "insert into composedocument set assignmenttitle='".$atitle."', comments='".$dets."',username='".$_SESSION['user_id']."',types='compose', title_reference='".$tr_post."'";
	$res = mysql_query($sql);
	$main_id_compose_for_continue = mysql_insert_id();
	/*if(isset($_SESSION['file1']) && $_SESSION['file1'] == $s_upload_file1) {
		$da->insertComposeMain($s_upload_file1);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file1);
		
		// remove temp
		$da->remove_temp($s_upload_file1);
	}
	if(isset($_SESSION['file2']) && $_SESSION['file2'] == $s_upload_file2) {
		$da->insertComposeMain($s_upload_file2);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file2);
		
		// remove temp
		$da->remove_temp($s_upload_file2);
	}
	if(isset($_SESSION['file3']) && $_SESSION['file3'] == $s_upload_file3) {
		$da->insertComposeMain($s_upload_file3);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file3);
		
		// remove temp
		$da->remove_temp($s_upload_file3);
	}
	if(isset($_SESSION['file4']) && $_SESSION['file4'] == $s_upload_file4) {
		$da->insertComposeMain($s_upload_file4);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file4);
		
		// remove temp
		$da->remove_temp($s_upload_file4);
	}
	if(isset($_SESSION['file5']) && $_SESSION['file5'] == $s_upload_file5) {
		$da->insertComposeMain($s_upload_file5);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file5);
		
		// remove temp
		$da->remove_temp($s_upload_file5);
	}
	if(isset($_SESSION['file6']) && $_SESSION['file6'] == $s_upload_file6) {
		$da->insertComposeMain($s_upload_file6);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file6);
		
		// remove temp
		$da->remove_temp($s_upload_file6);
	}
	if(isset($_SESSION['file7']) && $_SESSION['file7'] == $s_upload_file7) {
		$da->insertComposeMain($s_upload_file7);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file7);
		
		// remove temp
		$da->remove_temp($s_upload_file7);
	}
	if(isset($_SESSION['file8']) && $_SESSION['file8'] == $s_upload_file8) {
		$da->insertComposeMain($s_upload_file8);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file8);
		
		// remove temp
		$da->remove_temp($s_upload_file8);
	}
	if(isset($_SESSION['file9']) && $_SESSION['file9'] == $s_upload_file9) {
		$da->insertComposeMain($s_upload_file9);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file9);
		
		// remove temp
		$da->remove_temp($s_upload_file9);
	}
	if(isset($_SESSION['file10']) && $_SESSION['file10'] == $s_upload_file10) {
		$da->insertComposeMain($s_upload_file10);
		
		// get lastest id 
		$lastest_id = $da->last_inserted_id();
		
		// update again to pdfterms for main compose id
		$da->updatePdfTerms_main($lastest_id, $s_upload_file10);
		
		// remove temp
		$da->remove_temp($s_upload_file10);
	}*/
	header('location:index.php?page=assignment_manager&_v=c');
	}	
}

$edit = mysql_fetch_array(mysql_query("select * from composedocument where id='".$_GET['_e']."'"));
if(isset($_POST['Search']))
{
	header('location:index.php?page=assignment_manager&key='.$_POST['keywords']);
	//echo "<script>location.href='index.php?page=assignment_manager&key=".$_POST['keywords']."';<//script>";
}
/////////////////// Activate Product Category //////////////////////
if(isset($_REQUEST['AllActive']))
{
	$count=mysql_num_rows(mysql_query("select * from resource_centre"));
	for($i=0;$i<$count;$i++)
	{
		$del_id = $_POST['chk'][$i];
		if($del_id!=""){
		$all=mysql_fetch_array(mysql_query("select * from resource_centre where id='".$del_id."'"));
		$result  = "insert into composedocument set types='journal',journaltitle='".$all['book_title']."',";
		$result .= "publisher='".$all['publisher']."',pcity='".$all['city']."',pyear='".$all['year']."',";
		$result .= "edition='".$all['edition']."',issuenumber='".$all['issuenumber']."',pagenumber='".$all['pagenumber']."',";
		$result .= "firstname='".$all['firstname']."',lastname='".$all['lastname']."',username='".$_SESSION['user_id']."',";
		$result .= "booktitle='".$all['concept']."'";
		$exe = mysql_query($result);
		}
	}
	if($exe)
	header('location:index.php?page=assignment_manager');
}

/////////////////// Selected Articles add to articles //////////////////////
if(isset($_REQUEST['AllArticles']))
{
	$count=mysql_num_rows(mysql_query("select * from composedocument where username='".$_SESSION['user_id']."' and types='compose' order by id DESC"));
	$ids = '';
	for($i=0;$i<$count;$i++)
	{
		$del_id = $_POST['chks'][$i];
		if($del_id!=""){
			$ids.= $del_id.",";
		}
	}
	if($ids!="")
		header("location:index.php?page=assignment_manager&view=add_assign&_t=comp&ids=".$ids);
	//echo "<script>location.href='index.php?page=assignment_manager&view=add_assign&_t=comp&ids=".$ids."';<//script>";
}

if(isset($_GET['ids']))
{
	$display="block;";
}
else
{
	$display="none;";
}
?>
<div class="mainWarpArea" style="padding:0; margin:0;">
    <!-- Begin contentwarp -->
    <div class="contentwarp">
      <div id="register" style="background-color:#FFF;float:left;width:980px;border:0px solid #CCC;">
        <!-- Begin ContentBox -->
 
  		<h2 style="padding-left: 20px;" class="classifiedstitle"><span style="color:#00619C">Assignment Wizard</span></h2>
 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
     <td id="tdResourceCentre" style="display:<?=$display?>" width="25%" rowspan="2" align="center" valign="top" class="font12">
    <form action="" method="post" name="forms">
    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="borders">
      <tr>
        <td height="20" colspan="2" align="center" valign="middle" class="font12">RESOURCE CENTRE</td>
        </tr>
      <tr>
        <td height="1" colspan="3" align="center" valign="middle" bgcolor="#E4E4E4" class="font12"></td>
      </tr>
        <tr>
        <td height="10" colspan="3" align="center" valign="middle" class="font12"></td>
      </tr>  
      <tr>
        <td align="center" valign="middle">
        <input type="text" name="keywords" id="keywords" style="width:185px;" value="<?php echo $_GET['key']?>" class="txtborder" /></td>
        <td align="center" valign="middle">
        <input type="submit" name="Search" value="" class="searchbutton" /></td>
        </tr>
      <tr>
        <td colspan="2" align="center" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="center" valign="middle">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <?php
		  if(isset($_GET['key'])){
		  $list = mysql_query("select * from resource_centre where concept like '%".$_GET['key']."%'");
		  while($key = mysql_fetch_array($list)){
          ?>
          <tr>
            <td width="12%"><input type="checkbox" name="chk[]" id="chk" value="<?php echo $key['id']?>"/></td>
            <td width="88%" class="font12"><b>
			<A href="<?php echo $key['url']?>" target="_blank" class="font12"><?php echo $key['concept']?></A></b></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td class="font12" style="font-size:10px; color:#666;">
            <?php echo $key['firstname']." ".$key['lastname'];?>. (<?php echo $key['year'];?>). <?php echo $key['book_title'];?>, <?php echo $key['edition'];?>(<?php echo $key['issuenumber'];?>), <?php echo $key['pagenumber'];?>, <?php echo $key['city'];?>.</td>
          </tr>
          <tr>
            <td height="5" colspan="2"></td>
          </tr>
          <?php }}?>
          <tr>
            <td>&nbsp;</td>
            <td class="font12" style="font-size:10px; color:#666;">&nbsp;</td>
          </tr>
          <?php if(isset($_GET['key'])){
			  $tot = mysql_num_rows($list);
			  if($tot>0){
			  ?>
          <tr>
            <td colspan="2"><input type="submit" name="AllActive" class="buttonbg" style="width:120px;" value="ADD REFERENCE" title="ADD REFERENCE" /></td>
            </tr>
            <?php }else{echo "<span class='red'>- No REFERENCE Found -</span>";}}?>
        </table>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <!-- list of on doing assignment -->
	  <?php if(isset($_SESSION['user_id'])) { ?>
      <tr>
        <td height="30" colspan="2" align="center" valign="middle" id="radientbox" class="font12">LIST OF ON DOING ASSIGNMENTS</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td height="10" colspan="3"></td>
				  </tr>
				<?php
					$list_doing_assignment = mysql_query("SELECT * FROM composedocument_temp WHERE username='".$_SESSION['user_id']."'");
					$i = 1;
					while($list_d_a = mysql_fetch_array($list_doing_assignment)) {
						echo "<tr>";
						echo "<td width='10px' align=\"center\" style=\"padding-left: 5px;\">$i.</td>";
						echo "<td style=\"padding-left: 5px;\">".$list_d_a['assignmenttitle']."</td>";
						echo "<td align=\"right\" style=\"padding-right: 10px;\"><a href=\"?index.php&page=assignment_manager&view=continue_assign&id=".$list_d_a['id']."\"><img src=\"./images/edit.jpg\" border=\"0\" title=\"EDIT\" alt=\"EDIT\" /></a></td>";
						echo "</tr>";
					$i++;
					}
				?>
				<tr>
					<td height="5" colspan="3"></td>
				  </tr>
				  <tr>
					<td height="1" bgcolor="#E4E4E4" colspan="3"></td>
				  </tr>
				  <tr>
					<td height="5" colspan="3"></td>
				  </tr>
			</table>
		</td>
      </tr>
	  <?php } ?>
	  <!-- end list of on doing assignment -->
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="center" valign="middle" class="font12">ASSIGNMENT</td>
        </tr>
      <tr>
        <td height="1" colspan="3" align="center" valign="middle" bgcolor="#E4E4E4" class="font12"></td>
      </tr>
      <tr>
        <td colspan="2" align="center" valign="middle" class="font12">&nbsp;</td>
      </tr>
      <tr>
        <td height="20" colspan="2" align="center" valign="middle" class="font12">
        <div style="height:300px; overflow:auto;">
        <table width="100%" style="width:200px;" border="0" cellspacing="0" cellpadding="0" class="borders">
          <?php
		  $listaa = mysql_query("select * from composedocument where username='".$_SESSION['user_id']."' and types='compose' order by id DESC");
		  while($keya = mysql_fetch_array($listaa)){
          ?>
          <tr>
            <td width="12%" align="center" valign="top">
            <input type="checkbox" name="chks[]" id="chks" value="<?php echo $keya['id']?>"/></td>
            <td width="88%" align="left" valign="middle" class="font12">
			<?php $tt = $keya['comments'];
			$dd=strip_tags($tt,'');
			echo substr($dd,0,100)."...";			
			?><a href="javascript:void(0)" onclick="delete_assignment('<?php echo $keya['id']; ?>,this')">&nbsp;&nbsp;Delete<a></td>
          </tr>
          <tr>
            <td height="1" colspan="2" style="padding:5px;">
            	<div style="border-bottom:solid 1px #E4E4E4;height:1px;"></div>
            </td>
          </tr>    
          <?php }?>
          <tr>
            <td>&nbsp;</td>
            <td class="font12" style="font-size:10px; color:#666;">&nbsp;</td>
          </tr>
          <?php 
			  $totA = mysql_num_rows($listaa);
			  if($totA>0){
			  ?>
          <tr>
            <td colspan="2">
            <input type="submit" name="AllArticles" class="buttonbg" style="width:120px;" value="ADD ASSIGNMENT" title="ADD ASSIGNMENT" /></td>
            </tr>
            <?php }else{echo "<span class='red'>- No ASSIGNMENT Found -</span>";}?>
        </table>
        </div>
        </td>
      </tr>
      <tr>
        <td height="20" colspan="2" align="center" valign="middle" class="font12">&nbsp;</td>
      </tr>
      </table>
      </form>
      </td>
    <td width="45%" align="center" valign="top">
   
      <div id="menu4" >
	 
      <form action="" method="post" name="form4" enctype="multipart/form-data" onsubmit="return check_empty();">
      <table width="85%" border="0" align="center" cellpadding="0" cellspacing="0" class="borders" style="border:1px solid #FCB90F;">
      <tr>
        <td colspan="4" align="left" valign="middle" class="font12">&nbsp;</td>
      </tr>
      <tr>
        <td height="30" colspan="4" align="left" valign="middle" class="font12">
        <?php
		$get = explode(",",$_GET['ids']);
		/*//$get = explode(",",$ids);
		$cut = count($get);
		for($i=0;$i<$cut;$i++){
        $count=mysql_fetch_array(mysql_query("select id,comments from composedocument where id='".$get[$i]."'"));
		$comments .= $count['comments']."<br /><br />";
		} */ 
		//Commented By Vineet
		
		
		
		/* $citationlist = mysql_query("select CONCAT(  '<b>', lastname,  ', ', firstname,  '</b><br>', booktitle,  ', (', pyear,  ')' ) AS citation,  CONCAT('(',lastname,', ',pyear,')') as citationToInsert from composedocument where username='".$_SESSION['user_id']."' and types!='compose' order by id DESC");
		$citationListForJS = "\"[{";
		$i = 1;
		$citationListToInsertForJS = "\"";
		while($citation = mysql_fetch_array($citationlist)){
			$citationListForJS .= "'citation_".$i."':'".$citation['citation']."',";
			$citationListToInsertForJS .= "'".$citation['citationToInsert']."',";
			$i++;
		}
		$citationListForJS = substr($citationListForJS,0,(strlen($citationListForJS)-1));
		$citationListToInsertForJS = substr($citationListToInsertForJS,0,(strlen($citationListToInsertForJS)-1));
		$citationListForJS .= "}]\"";
		$citationListToInsertForJS .= "\"";
		echo "<script>citationList = ".$citationListForJS.";citationToInsert = ".$citationListToInsertForJS.";</script>"; */
		
		//Added by Vineet
		$get = explode(",",$ids);
		$count = count($get);
		if(count > 0)
		{
			$rs=mysql_fetch_array(mysql_query("select * from composedocument where id='".$get[0]."'"));
			$comments = $rs['comments']."<br /><br />";
		}
		?>
        <?php
			$sql = "SELECT * FROM temp_data_offline WHERE userid='".$_SESSION['user_id']."' ORDER BY id DESC LIMIT 1";
			$res = mysql_query($sql);
			$detail_temp = mysql_fetch_array($res);
		?>
        <div style="padding-left: 5px;"><span>Assignment Title</span>&nbsp;&nbsp;&nbsp;<span><input type="text" name="assignment_title" id="assignment_title" size="30" maxlength="255" value="<?php echo $detail_temp['assignmenttitle']; ?>" /></span>
		<?php if ($_GET['tr']){ ?>
		<input type="button" value="Search relevant sources" onclick="searchRelevantAssigment()"/>
		<?php } ?>
		</div>
        <br />
        <?php 
			if($detail_temp['comment']) {
				echo "<div><b>Your last comment:</b><br /><br />
					<div name=\"area2\" style=\"padding-left: 10px;\"><i>".$detail_temp['comment']."</i></div><br />
					</div>";	
			}
		?>
		<div id="test_ed1">
        <div id="richTextBox" contenteditable="false" style="width: 692px; margin: 4px; overflow: hidden;" class="nicEdit-main" onclick="ktra();">
        <textarea name="area1" id="richTextBox" class="txt-200" cols="50" style="height:200px; width:700px;" onblur="ktra();"></textarea></div>
        
	        <div id="tooltip">
	        	<div class="p-arrowTooltip p-arrowTooltip-top">
	        		<div id="tooltipTopLeft" class="arrowTooltip"></div>
	        		<div id="tooltipTopRight" class="arrowTooltip"></div>
	        		<div class="clear"></div>
	        	</div>
				<div id="tooltipInner" class="tooltip-standard">					
		            <div class="toolbar">
		                <div id="tooltip-toolbar-close" class="toolbar-close">
		                </div>
		                <span id="tooltipHeader" class="tooltipHeader">Header</span>
		                <div style="clear: both">
		                </div>
		            </div>
		            <div class="tooltip-content">
		                <div class="definition">
		                    <span id="tooltipDefinition"></span>
		                    <p class="link">
		                        See more <a href="#" target="_blank" id="tooltipLink"></a>
		                    </p>
		                </div>
		            </div>
		        </div>
				<div class="p-arrowTooltip p-arrowTooltip-bottom">
	        		<div id="tooltipBottomLeft" class="arrowTooltip"></div>
	        		<div id="tooltipBottomRight" class="arrowTooltip"></div>
	        		<div class="clear"></div>
	        	</div>
			</div>
	        <div id="suggestion" class="tooltip-standard">
	            <div class="toolbar">
	                <div id="suggestion-toolbar-close" class="toolbar-close">
	                </div>
	                <span id="suggestionHeader" class="tooltipHeader">Header</span>
	                <div style="clear: both">
	                </div>
	            </div>
	            <div class="tooltip-content">
	                <div id="suggestionContent" class="definition left">
		                <span id="quoteHeader"></span>
		                <span id="spSuggestionContent"></span>
		                <span id="quoteFooter"></span>
	                </div>
	                <div class="suggestionFunction right">
	                	<input id ="addLineBefore" type="button" value="Add line brefore"/>
	                	<input id="reduceLineBefore" type="button" value="Reduce line brefore"/>
	                	<input id ="addLineAfter" type="button" value="Add line after"/>
	                	<input id ="reduceLineAfter" type="button" value="Reduce line after"/>
	                	<input id="copySugguestion" type="button" value="Copy"/>
	                </div>
	                <div class="clear"></div>
	                <div class="sugguestion-format">Words: <span id="wordsSuggestion"></span><span id="quoteFormats">			                	
	                </span></div>
	            </div>
	        </div>
            </div>
        <div id="test_ed2" style="display:none"></div>
        </td>
        </tr>
      <tr>
        <td colspan="4" align="right" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="4" align="left" valign="middle" bgcolor="#FCB90F"></td>
        </tr>
		<tr>
        <td width="3%" height="100" align="left" valign="middle"></td>
        <td width="52%" height="100" align="left" valign="middle">
        	<table width="100%">
            	<tr>
                	<td width="40%" align="left">
                        <div id="btn_upload" style="color: #000000; display:none;">Upload File</div>
                        <div id="btn_upload2" style="color: #000000; display:none;">Upload more files</div>
                        <div id="btn_upload3" style="color: #000000; display:none;">Upload more files</div>
                        <div id="btn_upload4" style="color: #000000; display:none;">Upload more files</div>
                        <div id="btn_upload5" style="color: #000000; display:none;">Upload more files</div>
                        <div id="btn_upload6" style="color: #000000; display:none;">Upload more files</div>
                        <div id="btn_upload7" style="color: #000000; display:none;">Upload more files</div>
                        <div id="btn_upload8" style="color: #000000; display:none;">Upload more files</div>
                        <div id="btn_upload9" style="color: #000000; display:none;">Upload more files</div>
                        <div id="btn_upload10" style="color: #000000; display:none;">Upload more files</div>
                    </td>
                    <td width="20%">&nbsp;</td>
                    <td width="40%" align="left">
                    </td>
                </tr>
            </table>
            
        </td>
        <td width="13%" height="100" align="left" valign="middle"></td>
        <td width="32%" height="100" align="left" valign="middle"></td>
        </tr>
      <tr>
        <td height="1" colspan="4" align="left" valign="middle" bgcolor="#FCB90F"></td>
        </tr>
        <tr>
        <td colspan="4" align="left" height="10" valign="middle"></td>
      </tr>
      <tr>
        <td colspan="4" align="center" valign="middle">
        <input type="submit" name="SubmitCompose" class="buttonbg" style="width:180px;" value="Save Draft Assignment" />
		<!--&nbsp;<input type="submit" name="SaveToAccount" class="buttonbg" onclick="return SaveAssignmentToAccount('form4');" style="width:150px;" value="Save To Account" />-->
		&nbsp;<input type="button" name="back" class="buttonbg" onclick="javascript:location.href='index.php?page=assignment_manager';" style="width:100px;" value="Back" />		
		</td>
      </tr>
      <!-- hidden filename for using in continue or add -->
      <input type="hidden" name="tr_post" id="tr_post" value="<?php echo $tr; ?>" />
      <input type="hidden" name="s_upload_file1" id="s_upload_file1" value="" />
      <input type="hidden" name="s_upload_file2" id="s_upload_file2" value="" />
      <input type="hidden" name="s_upload_file3" id="s_upload_file3" value="" />
      <input type="hidden" name="s_upload_file4" id="s_upload_file4" value="" />
      <input type="hidden" name="s_upload_file5" id="s_upload_file5" value="" />
      <input type="hidden" name="s_upload_file6" id="s_upload_file6" value="" />
      <input type="hidden" name="s_upload_file7" id="s_upload_file7" value="" />
      <input type="hidden" name="s_upload_file8" id="s_upload_file8" value="" />
      <input type="hidden" name="s_upload_file9" id="s_upload_file9" value="" />
      <input type="hidden" name="s_upload_file10" id="s_upload_file10" value="" />
      <input type="hidden" name="userid" id="userid" value="<?php echo $_SESSION['user_id']; ?>" />
      <input type="hidden" name="assignment_id" id="assignment_id" value="0" />      
      <!-- ////////////////// end ///////////////////// -->
      </table>
      </form>
      <!-- upload file list appear & reference info -->
      <br /><div id="wrapall" style="display:none;">
          <table width="100%" border="0" cellpadding="0" cellspacing="0">
          	<tr>
            	<td width="50%" valign="top">
                	<div id="wrap_detail" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 1:&nbsp;&nbsp;</div><div id="detail" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel1" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio" id="book_journal1" name="book_journal" value="0" onclick="show_generate_reference(0, 1);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_1" name="book_journal" value="1" onclick="show_generate_reference(1, 1);" />Journal</span></div>
                    <br /></div>
                  </div>
                  <div id="wrap_detail2" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 2:&nbsp;&nbsp;</div><div id="detail2" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel2" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal2" name="book_journal2" value="0" onclick="show_generate_reference(0, 2);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_2" name="book_journal2" value="1" onclick="show_generate_reference(1, 2);" />Journal</span></div>
                    <br /></div>
                  </div>
                  <div id="wrap_detail3" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 3:&nbsp;&nbsp;</div><div id="detail3" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel3" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal3" name="book_journal3" value="0" onclick="show_generate_reference(0, 3);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_3" name="book_journal3" value="1" onclick="show_generate_reference(1, 3);" />Journal</span></div>
                    <br /></div>
                  </div>
                  <div id="wrap_detail4" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 4:&nbsp;&nbsp;</div><div id="detail4" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel4" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal4" name="book_journal4" value="0" onclick="show_generate_reference(0, 4);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_4" name="book_journal4" value="1" onclick="show_generate_reference(1, 4);" />Journal</span></div>
                    <br /></div>
                  </div>
                  <div id="wrap_detail5" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 5:&nbsp;&nbsp;</div><div id="detail5" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel5" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal5" name="book_journal5" value="0" onclick="show_generate_reference(0, 5);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_5" name="book_journal5" value="1" onclick="show_generate_reference(1, 5);" />Journal</span></div>
                    <br /></div>
                  </div>
                  <div id="wrap_detail6" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 6:&nbsp;&nbsp;</div><div id="detail6" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel6" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal6" name="book_journal6" value="0" onclick="show_generate_reference(0, 6);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_6" name="book_journal6" value="1" onclick="show_generate_reference(1, 6);" />Journal</span></div>
                    <br /></div>
                  </div>
                  <div id="wrap_detail7" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 7:&nbsp;&nbsp;</div><div id="detail7" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel7" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal7" name="book_journal7" value="0" onclick="show_generate_reference(0, 7);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_7" name="book_journal7" value="1" onclick="show_generate_reference(1, 7);" />Journal</span></div>
                    <br /></div>
                  </div>
                  <div id="wrap_detail8" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 8:&nbsp;&nbsp;</div><div id="detail8" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel8" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal8" name="book_journal8" value="0" onclick="show_generate_reference(0, 8);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_8" name="book_journal8" value="1" onclick="show_generate_reference(1, 8);" />Journal</span></div>
                    <br /></div>
                  </div>
                  <div id="wrap_detail9" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 9:&nbsp;&nbsp;</div><div id="detail9" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel9" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal9" name="book_journal9" value="0" onclick="show_generate_reference(0, 9);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_9" name="book_journal9" value="1" onclick="show_generate_reference(1, 9);" />Journal</span></div>
                    <br /></div>
                  </div>
                  <div id="wrap_detail10" style="display:none;">
                    <div style="float:left; cursor: pointer; color: #0000FF;padding-top: 5px;padding-left: 5px;">File 10:&nbsp;&nbsp;</div><div id="detail10" class="text makeup" style="float:left; padding-left: 10px;"></div>
                    <div style="clear:both;"></div>
                    <div align="left" style="color: #0000FF;"><span id="cancel10" style="cursor: pointer;"><img src="./images/delete.jpg" border="0" title="Cancel" alt="Cancel" />&nbsp;Cancel</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal10" name="book_journal10" value="0" onclick="show_generate_reference(0, 10);" />Books</span>
                    <span>&nbsp;&nbsp;<input type="radio"  id="book_journal_10" name="book_journal10" value="1" onclick="show_generate_reference(1, 10);" />Journal</span></div>
                    <br /></div>
                  </div>
                </td>
                <td width="50%" valign="top">
                	<div id="generate_reference_book" style="display:none">
                    	<div id="fromfile1"></div>
                        <!-- book info -->
                        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="30" colspan="4" align="left" valign="middle" class="font12" style="color:#2964BA;"><b>Book Info</b></td>
            </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td width="41%" height="25" align="right" valign="middle" class="font12">Title of the Book</td>
                <td width="7%" align="center" valign="middle" class="red">*</td>
                <td width="52%" align="left" valign="middle">
                <input type="text" name="title1" id="title1" class="txtborder" value="" />
                </td>
              </tr>
              <tr>
                <td height="25" align="right" valign="middle" class="font12">Publisher</td>
                <td align="center" valign="middle" class="red">*</td>
                <td align="left" valign="middle">
                <input type="text" name="pub1" id="pub1" class="txtborder" value="" /></td>
              </tr>
              <tr>
                <td height="25" align="right" valign="middle" class="font12">Publisher's City</td>
                <td align="center" valign="middle" class="red">*</td>
                <td align="left" valign="middle">
                <input type="text" name="pcity1" id="pcity1" class="txtborder" value="" /></td>
              </tr>
              <tr>
                <td height="25" align="right" valign="middle" class="font12">Year Published</td>
                <td align="center" valign="middle" class="red">*</td>
                <td align="left" valign="middle">
                <input type="text" name="date1" id="date1" class="txtborder" value="" /></td>
              </tr>
              <tr>
                <td height="25" align="right" valign="middle" class="font12">Edition</td>
                <td align="center" valign="middle">&nbsp;</td>
                <td align="left" valign="middle">
                <select name="edition1" id="edition1" class="txtborder" style="width:143px;">
				  <option value=""></option>
                  <option value="1st ed.">1st Edition</option>
                  <option value="2nd ed.">2nd Edition</option>
                  <option value="3rd ed.">3rd Edition</option>
                  <option value="4th ed.">4th Edition</option>
                  <option value="5th ed.">5th Edition</option>
                  <option value="6th ed.">6th Edition</option>
                  <option value="7th ed.">7th Edition</option>
                  <option value="8th ed.">8th Edition</option>
                  <option value="9th ed.">9th Edition</option>
                  <option value="10th ed.">10th Edition</option>
                  <option value="11th ed.">11th Edition</option>
                  <option value="12th ed.">12th Edition</option>
                  <option value="13th ed.">13th Edition</option>
                  <option value="14th ed.">14th Edition</option>
                  <option value="15th ed.">15th Edition</option>
                  <option value="16th ed.">16th Edition</option>
                  <option value="17th ed.">17th Edition</option>
                  <option value="18th ed.">18th Edition</option>
                  <option value="19th ed.">19th Edition</option>
                  <option value="20th ed.">20th Edition</option>
                </select></td>
              </tr>              
            </table></td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">&nbsp;</td>
          </tr>
          <tr>
            <td height="1" colspan="4" align="left" valign="middle" bgcolor="#8B98C9"></td>
            </tr>
            <tr>
            <td colspan="4" align="left" height="10" valign="middle"></td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle" class="font12" style="color:#2964BA;"><b>Author Name(s)</b></td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td width="8%" height="25" align="center" valign="middle" class="font12">&nbsp;</td>
                <td width="43%" align="left" valign="middle" class="font12">First Name</td>
                <td colspan="2" align="left" valign="middle" class="font12">Last Name</td>
                </tr>
              <tr>
                <td align="center" valign="middle">&nbsp;</td>
                <td align="left" valign="middle">
                <INPUT type="text" id="firstname1" name="firstname1" class="txtborder" value="" /></td>
                <td height="25" colspan="2" align="left" valign="middle">
                  <INPUT type="text" name="lastname1" id="lastname1" class="txtborder" value="" /></td>
                </tr>
              <tr>
                <td colspan="4" align="center" valign="middle">
                <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" id="dataTable1">
                    <?php 
                    $aut = explode(",",$edit['author']);
                    $bcout = count($aut);
                    for($i=0;$i<$bcout;$i++){
                        $names = explode("`",$aut[$i]);
                    ?>
                    <tr>
                        <td width="25"><INPUT type="checkbox" name="chk1[]"/></td>
                        <td width="166" >
                        <INPUT type="text" name="txt1[]" class="txtborder" value="" /></td>
                        <td width="194" align="left">
                        <INPUT type="text"  name="country1[]" class="txtborder" value="" /></td>
                    </tr>
                    <?php }?>
                </TABLE>
                </td>
                </tr>
              <tr>
                <td align="center" valign="middle">
                <INPUT type="button"  style="color:#FFF; background-color:#2964BA; border:#FFF solid 1px; width:20px;" value="-" onclick="deleteRow('dataTable1')" />
                </td>
                <td colspan="3" align="center" valign="middle" class="font12" style="font-size:10px; color:#999;">
                  <span style="float:left;">selected will be remove</span>
                  <INPUT type="button" style="color:#FFF; background-color:#2964BA; border:#FFF solid 1px; width:20px; " value="+" onclick="addRow('dataTable1')" />
                </td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">&nbsp;</td>
          </tr>
          <tr>
            <td height="1" colspan="4" align="left" valign="middle" bgcolor="#8B98C9"></td>
            </tr>
            <tr>
            <td colspan="4" align="left" height="10" valign="middle"></td>
          </tr>
          <tr>
            <td colspan="4" align="center" valign="middle">
            <input type="button" id="submit_book" name="SubmitBook" class="buttonbg" style="width:180px;" value="Generate References" /></td>
          </tr>
          </table>
                        <!-- end book info -->
                    </div>
                    <div id="generate_reference_journal" style="display:none">
                    	<div id="fromfile2"></div>
                        <!-- journal article info -->
                        <div>
                        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
        <td height="30" colspan="4" align="left" valign="middle" class="font12" style="color:#4DB332;"><b>Journal Article Info</b></td>
        </tr>
      <tr>
        <td colspan="4" align="left" valign="middle"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="45%" height="25" align="right" valign="middle" class="font12">Title of the Article</td>
            <td width="7%" align="center" valign="middle" class="red">*</td>
            <td width="48%" align="left" valign="middle">
            <input type="text" name="title2" id="title2" class="txtborder" value="" />
            </td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Title of the journal</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="journal2" id="journal2" class="txtborder" value="" />
            </td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Volume number</td>
            <td align="center" valign="middle" class="red">&nbsp;</td>
            <td align="left" valign="middle">
            <input type="text" name="edition2" id="edition2" class="txtborder" value="" />
            </td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Issue number</td>
            <td align="center" valign="middle" class="red">&nbsp;</td>
            <td align="left" valign="middle">
            <input type="text" name="issue2" id="issue2" class="txtborder" value="" />
            </td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Year Published</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
              <input type="text" name="date2" id="date2" class="txtborder" value="" /></td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Page numbers</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
              <input type="text" name="pages2" id="pages2" class="txtborder" value="" /></td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Digital Object Identifier(s)</td>
            <td align="center" valign="middle" class="red">&nbsp;</td>
            <td align="left" valign="middle">
            <input type="text" name="digital2" id="digital2" class="txtborder" value="" />
            </td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="4" align="left" valign="middle" bgcolor="#4DB332"></td>

        </tr>
        <tr>
        <td colspan="4" align="left" height="10" valign="middle"></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle" class="font12" style="color:#4DB332;"><b>Author Name(s)</b></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="8%" height="25" align="center" valign="middle" class="font12">&nbsp;</td>
            <td width="43%" align="left" valign="middle" class="font12">First Name</td>
            <td colspan="2" align="left" valign="middle" class="font12">Last Name</td>
            </tr>
          <tr>
            <td align="center" valign="middle">&nbsp;</td>
            <td align="left" valign="middle">
            <INPUT type="text"  name="firstname2" id="firstname2" class="txtborder" value="" ></td>
            <td height="25" colspan="2" align="left" valign="middle">
              <INPUT type="text" name="lastname2" id="lastname2" class="txtborder" value=""></td>
            </tr>
          <tr>
            <td colspan="4" align="center" valign="middle">
            <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" id="dataTable2">
                <?php 
				$aut2 = explode(",",$edit['author']);
				$bcout2 = count($aut2);
				for($i=0;$i<$bcout2;$i++){
					$names2 = explode("`",$aut2[$i]);
				?>
                <tr>
                    <td width="25"><INPUT type="checkbox" name="chk2[]"/></td>
                    <td width="166" ><INPUT type="text" name="txt2[]" class="txtborder" value="" />
                    </td>
                    <td width="194" align="left">
                      <INPUT type="text"  name="country2[]" class="txtborder" value="" /> 
                    </td>
                 </tr>
                 <?php }?>
            </TABLE>
            </td>
            </tr>
          <tr>
            <td align="center" valign="middle">
            <INPUT type="button"  style="color:#FFF; background-color:#4DB332; border:#FFF solid 1px; width:20px;" value="-" onclick="deleteRow('dataTable2')" />
            </td>
            <td colspan="3" align="center" valign="middle" class="font12" style="font-size:10px; color:#999;">
              <span style="float:left;">selected will be remove</span>
              <INPUT type="button" style="color:#FFF; background-color:#4DB332; border:#FFF solid 1px; width:20px; " value="+" onclick="addRow('dataTable2')" />
            </td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="4" align="left" valign="middle" bgcolor="#4DB332"></td>
        </tr>
        <tr>
        <td colspan="4" align="left" height="10" valign="middle"></td>
      </tr>
      <tr>
        <td colspan="4" align="center" valign="middle">
        <input type="submit" id="submit_journal" name="SubmitJournal" class="buttonbg" style="width:180px;" value="Generate References" /></td>
      </tr>
      </table>
                        </div>
                        <!-- end of journal -->
                    </div>
                </td>
            </tr>
          </table>
      </div>
      <!-- // end of this -->
      </td>
    <td width="30%" rowspan="2" align="center" valign="top" class="font12">
    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="borders">
      <tr>
        <td height="20" colspan="3" align="center" valign="middle" class="font12">REFERENCES</td>
        </tr>
      <tr>
        <td height="1" colspan="3" align="center" valign="middle" bgcolor="#E4E4E4" class="font12"></td>
      </tr>
        <tr>
        <td height="10" colspan="3" align="center" valign="middle" class="font12"></td>
      </tr>
      <tr>
        <td colspan="3" align="left" valign="top"  >
      <div style="height:300px; overflow:auto;">
		<div id="DelReference">
		  <!-- begin new citation for save to account -->  
          <?php $tr = isset($_GET['tr']) ? intval($_GET['tr']) : 0; ?>
		  <?php if($tr != 0) { ?>
          <?php
				include_once 'citation_list.php';
		  ?>
          <?php } else { ?>
          <div style="display:none">
		  <?php
				include_once 'citation_list.php';
		  ?>
          </div>
          <div>Please choose Reference for new Assignment<br />
          <table width="100%">
                        	<?php 
                            	$sql = "SELECT * FROM tbl_references WHERE User='".$UserID."' ORDER BY UpdatedDate DESC";
								$res = mysql_query($sql);
								//$list = mysql_fetch_array($res);
								//print_r($list);//exit;
								while($list = mysql_fetch_array($res)) {
                            ?>
                            <tr>
                            	<td class="ti_re"><a class="ti_re" href="./index.php?page=assignment_manager&view=add_assign&tr=<?php echo $list['ID']; ?>"><div><?php echo $list['Title_Reference']." @ ". date_format(new DateTime($list['UpdatedDate']),"m/d/y h:iA"); ?></div>
                                <?php 
									$sql2 = "SELECT COUNT(*) FROM composedocument WHERE username='".$UserID."' AND title_reference='".$list['ID']."' and types !='compose'";
									$res2 = mysql_query($sql2);
									$num = mysql_fetch_row($res2);
									if($num[0] > 1) {
										$num_str = $num[0]." citations";
									} else $num_str = $num[0]." citation";
								?>
                                <div class="ti_re2"><?php echo $num_str; ?></div>
                                </a></td>
                            </tr>
                            <?php } ?>
                        </table>
          </div>
          <?php } ?>
		<!-- end new citation for save to account -->
		</div>
    </div>
        </td>
      </tr>
      <tr>
        <td colspan="3" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="3" align="center" valign="middle" bgcolor="#E4E4E4" class="font12"></td>
      </tr>
      <tr>
        <td height="55" colspan="3" align="center" valign="middle" class="font12">
        	<A href="download.php"><img src="./images/download-icon.png" border="0" /></A>
        </td>
      </tr>
      <tr>
      	<td>
      		<div class="VideoBoxAssignment">
        	<?php 
	        $qry = "select * from video WHERE id = '2'";
			$res = $base_obj->exec_query($qry);
			$data = $base_obj->fetch_row($res);
		   	echo $data['url']; ?>
      	</td>      	        
        </div>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
    </tr>
        </table>
   	</div>      
      
     
      <!-- End contentwarp -->
       <?php include("includes/right_content.php");?>
      <div style="clear:both;"></div>
      
    </div>
    <!-- End mainWarpArea -->
  </div>
<script type="text/javascript" src="nicEdit-latest.js"></script> 
<script type="text/javascript" src="ext_nicEditor.js"></script> 
<script type="text/javascript">
//<![CDATA[
		bkLib.onDomLoaded(function() { 
			nicEditors.allTextAreas();
			loadEditableExtend();
		});
  //]]>
</script>
<?php echo $comments;?>